<?php include template('header','common');?>
<link rel="stylesheet" type="text/css" href="{__ROOT__}template/default/statics/css/qingjia.css?v={HD_VERSION}">
<div class="container">
	<div class="calendar">
		<div class="calendar-head">
			<a href="{url('member/index/index')}"><img src="{__ROOT__}template/default/statics/img/left.png" alt=""></a>
			<span><?php echo date("Y");?>年<?php echo date("m");?>月</span>
			<span></span>
		</div>
		<div class="calendar-content">
			<ul class="calendar-week">
				<li>日</li>
				<li>一</li>
				<li>二</li>
				<li>三</li>
				<li>四</li>
				<li>五</li>
				<li>六</li>
			</ul>
			
			<ul class="calendar-list">
				<?php foreach($week as $k => $v){?>		
				<li class="calendar-item">
					<?php foreach($v as $kk => $vv){?>	
					<div>
						<?php if(date("m") == $vv['m'] && date("d") > $vv['d']){?>
						<a class="active1" status="2">
                        <?php }elseif($vv['leave'] == 1 && date("m") == $vv['m'] && date("d") == $vv['d']){?>
						<a class="active select-date" status="0" date="{$vv['date']}">
                        <?php }elseif($vv['leave'] == 1 ){?>
                        <a class="active1" status="2">
						<?php }elseif($vv['point'] > 0){?>
						<a class="select-date active4" name="qingjia" status="2" date="{$vv['date']}">
						<?php }elseif(date("m") == $vv['m'] && date("d") == $vv['d']){?>
						<a class="active select-date" status="0" date="{$vv['date']}">
						<?php }elseif(date("Y") > $vv['y']){?>
						<a class="active1" status="2">
						<?php }else{?>
						<a status="0" class="select-date" date="{$vv['date']}">
						<?php }?>
						<span><?php if($vv['d'] == "01"){?>{$vv['mt']}月<?php }else{?>{$vv['d']}<?php }?></span>                            
						</a>
					</div>
					<?php }?>
				</li>
				<?php }?>
			</ul>
		</div>
		<div class="tishi">
			<img src="{__ROOT__}template/default/statics/img/ti-shi-.png" alt=""> 请于前一天18：00之前请假，退费（当天费用的{$bl}%）将在假期后计入您的余额 ；18：00之后也需要请假，平台会接收信息反馈给午托班老师但无法给予退费处理。<br />注：
			<span style="background:#ccc; padding:3px 5px;font-size:12px;">请假</span>&nbsp;<span style="background:#000; padding:3px 5px;font-size:12px; color:#fff;">选定</span>&nbsp;<span style="background:#ffae2e; padding:3px 5px;font-size:12px; color:#fff;">今天</span>
			<input type="hidden" name="student_id" value="{$student_id}" />
		</div>
	</div>
	<div class="btn-view" style="margin-bottom:80px;">
		<button class="btn">提交</button>
	</div>
</div>
<script>
$(".btn").click(function(){
	var date_value =[];//定义一个数组
	var ldate_value =[];//定义一个数组
	$(".active3").each(function(){
		if($(this).attr('status') < 2){
			date_value.push($(this).attr('date'));
		}
	});
	
	$("[name='qingjia']").each(function(){
		if($(this).attr('status') == 3){
			ldate_value.push($(this).attr('date'));
		}
	});
	if (date_value.length == 0 && ldate_value.length == 0) { 
		alerts("请选择您要请假的日期！"); 
		return ; 
	} 
	var ajaxurl="<?php echo url('member/point/ajaxleave')?>";
	$.post(ajaxurl,{'student_id':$("[name='student_id']").val(),'dates':date_value.toString(),'ldates':ldate_value.toString()},function(ret){
		if(ret.status == 1){
			alerts(ret.message,1,ret.referer);
		}else{
			alerts(ret.message);
		}
	},'json');
});
$(".select-date").click(function(){
	var status = $(this).attr('status');
	if(status == 0){
		$(this).addClass('active3');
		$(this).attr('status',1);
	}else{
		if(status == 2){
			$(this).removeClass('active4');
			$(this).removeClass('active3');
			$(this).attr('status',3);
		}else if(status == 3){
			$(this).addClass('active3');
			$(this).attr('status',2);
		}else{
			$(this).removeClass('active3');
			$(this).attr('status',0);
		}
	}
});
</script>
<?php include template('footer','common');?>